#!user/bin/env python3
# -- coding: utf-8 --
# @Createtime：2023/9/6 16:19
# @Updatetime：16:19
# @Author：Test008
# @File：6-广东省疫情分布图
# @Description：
import json

from pyecharts.charts import Map
from pyecharts.options import *

with open('../../../static/doc/yiqing_data/疫情.txt', 'r', encoding='utf-8') as f:
    json_data = f.read()
dict_data = json.loads(json_data)
gd_data = dict_data['areaTree'][0]['children'][7]['children']
all_city_list = []
for city_data in gd_data:
    city_name = city_data["name"]
    if len(city_name) == 2:
        city_name = city_data["name"] + "市"
    city_confirm = city_data['total']["confirm"]
    all_city_list.append((city_name, city_confirm))
all_city_list.append(("云浮市", 3))


map = (
    Map()
        .add('各市疫情分布图', all_city_list, "广东")
        .set_global_opts(
        title_opts=TitleOpts(title='2021年广东省各市疫情分布图'),
        visualmap_opts=VisualMapOpts(
            is_show=True,
            is_piecewise=True,
            pieces=[
                {"min": 0, "max": 25, "label": '0-25', "color": "#c4ccd3"},
                {"min": 25, "max": 50, "label": '25-50', "color": "#546570"},
                {"min": 50, "max": 100, "label": '50-100', "color": "#ef5b9c"},
                {"min": 100, "max": 500, "label": '100-500', "color": "#f05b72"},
                {"min": 500, "label": '500+', "color": "#c23531"}
            ]
        )
    )
        .render('2021年广东省各市疫情分布图.html')
)
